{include file="public/header" /}

<div class="layui-fluid">
    <div class="layui-row layui-col-space15">
        <div class="layui-col-md12">
            <div class="layui-card">
                <div class="layui-card-body ">
                    <form class="layui-form layui-col-space5">
                        <div class="layui-inline layui-show-xs-block">
                            <select name="order" class="layui-input">
                                <option value="">排序方式（默认）</option>
                                <option value="1" {if !empty(input('get.order')) && input('get.order')==1}selected{/if}>
                                    PDB从多到少排序
                                </option>
                                <option value="2" {if !empty(input('get.order')) && input('get.order')==2}selected{/if}>
                                    KCB从多到少排序
                                </option>
                                <option value="3" {if !empty(input('get.order')) && input('get.order')==3}selected{/if}>
                                    额度从多到少排序
                                </option>
                                <option value="4" {if !empty(input('get.order')) && input('get.order')==4}selected{/if}>
                                    算力从多到少排序
                                </option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <select name="level" class="layui-input">
                                <option value="">用户等级</option>
                                <option value="1" {if !empty(input('get.level')) && input('get.level')==1}selected{/if}>
                                    V1
                                </option>
                                <option value="2" {if !empty(input('get.level')) && input('get.level')==2}selected{/if}>
                                    V2
                                </option>
                                <option value="3" {if !empty(input('get.level')) && input('get.level')==3}selected{/if}>
                                    V3
                                </option>
                            </select>
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="mobile" placeholder="用户账号|ID" value="{:input('get.mobile')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="pmobile" placeholder="直推用户账号|ID" value="{:input('get.ppmobile')}"
                                autocomplete="off" class="layui-input">
                        </div>
                        <div class="layui-inline layui-show-xs-block">
                            <input type="text" name="ppmobile" placeholder="间推用户账号|ID" value="{:input('get.ppmobile')}"
                                autocomplete="off" class="layui-input">
                        </div>

                        <div class="layui-inline layui-show-xs-block">
                            <button class="layui-btn" lay-submit="" lay-filter="sreach">搜索</button>
                        </div>
                    </form>
                </div>
                <div class="layui-card-header">
                    <button class="layui-btn" onclick="data_edit('添加','user_add')"><i
                            class="layui-icon">&#xe654;</i>添加</button>&nbsp;
                    共有数据：<strong id="count">{$list->total()}</strong> 条
                </div>
                <div class="layui-card-body layui-table-body layui-table-main">
                    <table class="layui-table layui-form">
                        <thead>
                            <tr>
                                <th>用户ID</th>
                                <th>用户账号</th>
                                <th>是否实名</th>
                                <th>是否冻结</th>
                                <th>昵称</th>
                                <th>等级</th>
                                <th>信誉积分</th>
                                <th>资产信息</th>
                                <th>邀请码</th>
                                <th>直推用户信息</th>
                                <th>间推用户信息</th>
                                <th>注册时间</th>
                                <th>操作</th>
                            </tr>
                        </thead>
                        <tbody>
                            {foreach $list as $v}
                            <tr>
                                <td>{$v.id|default='0'}</td>
                                <td>{$v.mobile|default=''}</td>
                                <td>{if $v.userauth == 1}<button type="button"
                                        onclick="orderstr2('/user/userauthfast','{$v.id}',1)"
                                        class="layui-btn layui-bg-cyan">待实名</button>{else}已实名{/if}</td>
                                <td>{if $v.status == 0}
                                    <a title="通过" onclick="orderstr3('确认冻结账号？', '/user/statusstr', '{$v.id}', 1)"
                                        href="javascript:;" class="layui-btn layui-btn-normal">
                                        正常
                                    </a>
                                    {else}
                                    <a title="通过" onclick="orderstr3('确认解冻账号？', '/user/statusstr', '{$v.id}', 0)"
                                        href="javascript:;" class="layui-btn layui-btn">
                                        冻结
                                    </a>
                                    {/if}
                                </td>
                                <td>{$v.nickname|default=''}</td>
                                <td>V{$v.level|default=''}
                                </td>
                                <td> <button type="button" onclick="orderstr('/user/moneystr','{$v.id}',10)"
                                        class="layui-btn layui-bg-green">
                                        {$v.reputa|default=''}分
                                    </button>
                                </td>
                                <td>
                                    <button type="button"
                                        onclick="data_edit('查看','/user/moneylog?mobile={$v.mobile}&cointype=1')"
                                        class="layui-btn layui-bg-cyan">
                                        PDB:{$v.money|default=0}
                                    </button>
                                    <button type="button" onclick="orderstr('/user/moneystr','{$v.id}',1)"
                                        class="layui-btn layui-bg-cyan">
                                        <i class="layui-icon">&#xe654;</i>
                                    </button>
                                    <br />
                                    <button type="button"
                                        onclick="data_edit('查看','/user/moneylog?mobile={$v.mobile}&cointype=2')"
                                        class="layui-btn layui-bg-orange">
                                        KCB:{$v.amount|default=0}
                                    </button>
                                    <button type="button" onclick="orderstr('/user/moneystr','{$v.id}',2)"
                                        class="layui-btn layui-bg-orange">
                                        <i class="layui-icon">&#xe654;</i>
                                    </button>
                                    <br />
                                    <button type="button"
                                        onclick="data_edit('查看','/user/moneylog?mobile={$v.mobile}&cointype=3')"
                                        class="layui-btn layui-bg-blue">
                                        额度：{$v.quota|default=0}
                                    </button>
                                    <button type="button" onclick="orderstr('/user/moneystr','{$v.id}',3)"
                                        class="layui-btn layui-bg-blue">
                                        <i class="layui-icon">&#xe654;</i>
                                    </button>
                                    <br />
                                    <button type="button"
                                        onclick="data_edit('查看','/user/moneylog?mobile={$v.mobile}&cointype=4')"
                                        class="layui-btn layui-bg-red">
                                        推荐收益：{$v.assets|default=0}
                                    </button>
                                    <button type="button" onclick="orderstr('/user/moneystr','{$v.id}',4)"
                                        class="layui-btn layui-bg-red">
                                        <i class="layui-icon">&#xe654;</i>
                                    </button>
                                    <br />
                                    <button type="button"
                                        onclick="data_edit('查看','/user/moneylog?mobile={$v.mobile}&cointype=5')"
                                        class="layui-btn layui-bg-green">
                                        算力：{$v.power|default=0}
                                    </button>
                                    <button type="button" onclick="orderstr('/user/moneystr','{$v.id}',5)"
                                        class="layui-btn layui-bg-green">
                                        <i class="layui-icon">&#xe654;</i>
                                    </button>
                                    <br />
                                </td>
                                <td>{$v.code|default=''}</td>
                                <td>{if $v.pid > 0}ID:{$v.pid|default=''}<br />{$v.pmobile|default=''}{else}无{/if}</td>
                                <td>{if $v.ppid > 0}ID:{$v.ppid|default=''}<br />{$v.ppmobile|default=''}{else}无{/if}
                                </td>
                                <td>{$v.created|default=''}</td>
                                <td class="td-manage">
                                    <a title="编辑" onclick="data_edit('编辑','/user/user_edit?id={$v.id}')"
                                        href="javascript:;" class="layui-btn">
                                        编辑
                                    </a>
                                    <a title="赠送" onclick="data_edit('赠送','/user/giveminging?id={$v.id}')"
                                        href="javascript:;" class="layui-btn">
                                        赠送矿机
                                    </a>
                                    <a title="签到记录" onclick="data_edit('签到记录','/user/signlog?mobile={$v.id}')"
                                        href="javascript:;" class="layui-btn">
                                        签到记录
                                    </a>
                                    <a title="收款信息" onclick="data_edit('收款信息','/user/usersafety?mobile={$v.id}')"
                                        href="javascript:;" class="layui-btn">
                                        收款信息
                                    </a>
                                </td>
                            </tr>
                            {/foreach}

                        </tbody>
                    </table>
                </div>
                <div class="layui-card-body ">
                    <div class="page">
                        {$list->render()|raw}
                    </div>
                </div>

            </div>
        </div>
    </div>
</div>
</body>
<script>
    layui.use(['form', 'upload'], function () {
        var $ = layui.jquery
            , upload = layui.upload;
        //图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: 'users_top'
            , accept: 'file'
            , exts: 'xls|csv'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {
                //如果上传失败
                if (res.status > 0) {
                    return layer.msg(res.msg);
                }
                //上传成功
                return layer.msg(res.msg);
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    });

    function showimg(imgs) {
        console.log(imgs);
        layer.open({
            type: 1,
            title: false,
            shadeClose: true,
            skin: 'layui-layer-nobg', //没有背景色
            content: "<img src='" + imgs + "' style='width:100%;height: 100%;'>"
        });
    }
    function orderstr(url, user_id, type) {
        layer.prompt({
            value: '0',
            title: '修改资产，正数表示增加，负数表示减少',
        }, function (value, index, elem) {
            $.post(url, { id: user_id, type: type, money: value }, function (data) {
                if (data.status == 0) {
                    layer.msg(data.msg, { icon: 6, time: 1000 }, function () {
                        location.reload();
                        layer.close(index);
                    });
                } else {
                    layer.msg(data.msg, { icon: 2, time: 1000 });
                }
            });
        });
    }
    function orderstr2(url, user_id, type) {
        layer.open({
            type: 1,
            area: ['500px', '300px'],
            btn: ['提交', '取消'],
            content: '<table class="layui-table">\
                <colgroup><col width="50"> <col width="200"></colgroup>\
                <thead><tr><th>名称</th><th>内容</th></tr></thead>\
                <tbody><tr><td>姓名</td><td><input id="trackname" type="text" placeholder="请输入姓名"  class="layui-input"/></td></tr>\
                <tr><td>身份证号</td><td><input id="tracknum" type="text" placeholder="请输入身份证号"  class="layui-input"/></td></tr>\
                </tbody></table>',
            yes: function (index) {
                var tracknum = $('#tracknum').val();
                var trackname = $('#trackname').val();
                if (!tracknum || !trackname) {
                    layer.msg('姓名或身份证号不能为空');
                    return;
                }
                $.post(url, { id: user_id, name: tracknum, card_no: trackname }, function (res) {
                    if (res.status == 0) {
                        location.reload();
                        layer.close(index);
                        return;
                    } else {
                        layer.msg(data.msg, { icon: 2, time: 1000 });
                        return;
                    }
                });
            }
        });
    }
    function orderstr3(title, url, id, type) {
        layer.confirm(title, { title: '请谨慎操作' }, function (index) {
            $.post(url, { id: id, status: type }, function (data) {
                if (data.status == 0) {
                    layer.msg(data.msg, { icon: 6, time: 1000 }, function () {
                        location.reload();
                        layer.close(index);
                    });
                } else {
                    layer.msg(data.msg, { icon: 2, time: 1000 });
                }
            });
        });
    }
</script>
{include file="public/footer"}